package com.itxx.keyCase.Demo4;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class TcpServer {
    public static void main(String[] args) throws IOException {
        //1.创建ServerSocket对象
        ServerSocket ss = new ServerSocket(54321);
        //2.创建io流接受数据
        Socket accept = ss.accept();
        InputStream is = accept.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String s = br.readLine();
        System.out.println("这是同过TCp协议接受的数据:"+s);

        //3.释放资源
        br.close();
        accept.close();
    }
}
